package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.db.Question;
import com.itheima.mapper.QuestionMapper;
import com.itheima.service.db.QuestionService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author zsk
 * @create 2022-03-14-19:38
 */
@DubboService
public class QuestionServiceImpl implements QuestionService {

    //依赖注入
    @Autowired
    private QuestionMapper questionMapper;


    //根据userId查询陌生人问题模块
    @Override
    public Question findByUserId(Long userId) {
        //构建查询条件
        LambdaQueryWrapper<Question> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Question::getUserId,userId);
        //查询
        return questionMapper.selectOne(wrapper);
    }

    //新增问题
    @Override
    public void save(Question question) {
        questionMapper.insert(question);
    }

    //修改问题
    @Override
    public void update(Question question) {
        questionMapper.updateById(question);
    }
}
